<template>
  <!-- 添加商户 -->
  <el-dialog
    :title="titname"
    :visible.sync="dialogVisible"
    width="60%"
    center
    :before-close="handleClose"
  >
    <!-- 合伙人新增弹框 -->
    <addPartner
      :status.sync="dialogVisibles"
      @getCompanyName="getSonText"
      :editObj="{}"
    ></addPartner>
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      {{ companyName }}
      <el-form-item label="类 型" prop="name">
        <el-select
          v-model="ruleForm.name"
          placeholder="请选择类型"
          @change="selectClick"
        >
          <el-option
            v-for="item in statusLists"
            :key="item.key"
            :label="item.status_name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <div v-if="partnership">
        <el-form-item label="合作方包含" prop="partner">
          <div>
            <el-checkbox
              v-model="ruleForm.checked1"
              label="资源方"
              border
              @change="checked1"
            ></el-checkbox>
            <el-checkbox
              v-model="ruleForm.checked2"
              label="基建方"
              border
              @change="checked2"
            ></el-checkbox>
            <el-checkbox
              v-model="ruleForm.checked3"
              label="场地方"
              border
              @change="checked3"
            ></el-checkbox>
            <el-checkbox
              v-model="ruleForm.checked4"
              label="总设备方"
              border
              @change="checked4"
            ></el-checkbox>
            <el-checkbox
              v-model="ruleForm.checked5"
              label="子设备方"
              border
              @change="checked5"
            ></el-checkbox>
          </div>
        </el-form-item>
        <el-form-item class="partitle">
          <span class="font-12 color-FBB000"
            >*资源方、基建方、场地方、总设备方必须包含</span
          >
        </el-form-item>
        <el-form-item label="商户地区">
          <selectCity :cityVal.sync="ruleForm.cityVal" type="2" />
        </el-form-item>

        <!-- 测试statr -->
        <el-form-item
          label="所属资源方"
          prop="resourceside"
          v-show="resourceside"
        >
          <el-select
            v-model="ruleForm.resourceside"
            filterable
            remote
            placeholder="请选择所属资源方"
            :remote-method="remoteMethod"
            @change="resourcesideClick"
          >
            <el-option
              v-for="(item, index1) in resourcesideList"
              :key="item.storeid"
              :label="item.storename"
              :value="index1"
            >
            </el-option>
          </el-select>
          <span
            class="color-blue font-12 mt-10 ml-10"
            @click="returndetails(0)"
            style="cursor: pointer"
          >
            新增
          </span>
        </el-form-item>
        <!-- 测试end -->

        <!-- <el-form-item
          label="所属资源方"
          prop="resourceside"
          v-show="resourceside"
        >
          <el-select
            v-model="ruleForm.resourceside"
            placeholder="请选择所属资源方"
            class="selectcss"
            @change="resourcesideClick"
          >
            <el-option
              :label="item.storename"
              :value="index1"
              v-for="(item, index1) in resourcesideList"
              :key="index1"
            ></el-option>
          </el-select>
          <span
            class="color-blue font-12 mt-10 ml-10"
            @click="returndetails(0)"
            style="cursor: pointer"
          >
            新增
          </span>
        </el-form-item> -->
        
        <el-form-item
          label="所属基建方"
          prop="infrastructureside"
          v-show="infrastructureside"
        >
          <el-select
            v-model="ruleForm.infrastructureside"
            filterable
            remote
            placeholder="请选择所属基建方"
            :remote-method="remoteMethod"
            @change="infrastructuresideClick"
          >
            <el-option
              v-for="(item, index1) in resourcesideList"
              :key="item.storeid"
              :label="item.storename"
              :value="index1"
            >
            </el-option>
          </el-select>
          <span
            class="color-blue font-12 mt-10 ml-10"
            @click="returndetails(1)"
            style="cursor: pointer"
            >新增</span
          >
        </el-form-item>
        <el-form-item
          label="所属场地方"
          prop="venue"
          v-show="venue"
        >
          <el-select
            v-model="ruleForm.venue"
            filterable
            remote
            placeholder="请选择所属场地方"
            :remote-method="remoteMethod"
            @change="venueClick"
          >
            <el-option
              v-for="(item, index1) in resourcesideList"
              :key="item.storeid"
              :label="item.storename"
              :value="index1"
            >
            </el-option>
          </el-select>
          <span
            class="color-blue font-12 mt-10 ml-10"
            @click="returndetails(2)"
            style="cursor: pointer"
            >新增</span
          >
        </el-form-item>
        <el-form-item
          label="所属总设备方"
          prop="generalequipment"
          v-show="generalequipment"
          label-width="108"
        >
          <el-select
            v-model="ruleForm.generalequipment"
            filterable
            remote
            placeholder="请选择所属总设备方"
            :remote-method="remoteMethod"
            @change="generalequipmentClick"
          >
            <el-option
              v-for="(item, index1) in resourcesideList"
              :key="item.storeid"
              :label="item.storename"
              :value="index1"
            >
            </el-option>
          </el-select>
          <span
            class="color-blue font-12 mt-10 ml-10"
            @click="returndetails(3)"
            style="cursor: pointer"
            >新增</span
          >
        </el-form-item>
        <el-form-item
          label="所属子设备方"
          prop="subequipment"
          v-show="subequipment"
          label-width="108"
        >
          <el-select
            v-model="ruleForm.subequipment"
            filterable
            remote
            placeholder="请选择所属总设备方"
            :remote-method="remoteMethod"
            @change="subequipmentClick"
          >
            <el-option
              v-for="(item, index1) in resourcesideList"
              :key="item.storeid"
              :label="item.storename"
              :value="index1"
            >
            </el-option>
          </el-select>
          <span
            class="color-blue font-12 mt-10 ml-10"
            @click="returndetails(4)"
            style="cursor: pointer"
            >新增</span
          >
        </el-form-item>
        <el-form-item label="回本设置" width="180">
          <table class="tablecss">
            <thead>
              <tr>
                <th>回本方</th>
                <th>基建方</th>
                <th v-if="subequipment">子设备方</th>
                <th v-else>总设备方</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>是否回本</td>
                <td>
                  <el-form-item prop="basicsorigina">
                    <el-select
                      v-model="ruleForm.basicsorigina"
                      placeholder="请选择"
                      class="selectcss"
                      @change="basicsorigina"
                    >
                      <el-option label="是" value="1"></el-option>
                      <el-option label="否" value="0"></el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td v-if="subequipment">
                  <el-form-item prop="sonorigina">
                    <el-select
                      v-model="ruleForm.sonorigina"
                      placeholder="请选择"
                      class="selectcss"
                      @change="sonorigina"
                    >
                      <el-option label="是" value="1"></el-option>
                      <el-option label="否" value="0"></el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td v-else>
                  <el-form-item prop="Zsonorigina">
                    <el-select
                      v-model="ruleForm.Zsonorigina"
                      placeholder="请选择"
                      class="selectcss"
                      @change="Zsonorigina"
                    >
                      <el-option label="是" value="1"></el-option>
                      <el-option label="否" value="0"></el-option>
                    </el-select>
                  </el-form-item>
                </td>
              </tr>
            </tbody>
            <tbody>
              <tr>
                <td>回本顺序</td>
                <td>
                  <el-form-item prop="basicorder">
                    <el-select
                      v-model="ruleForm.basicorder"
                      placeholder="请选择"
                      class="selectcss"
                      @change="basicorder"
                    >
                      <el-option label="1" value="1"></el-option>
                      <el-option label="2" value="2"></el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td v-if="subequipment">
                  <el-form-item prop="sonorder">
                    <el-select
                      v-model="ruleForm.sonorder"
                      placeholder="请选择"
                      class="selectcss"
                      @change="sonorder"
                    >
                      <el-option label="1" value="1"></el-option>
                      <el-option label="2" value="2"></el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td v-else>
                  <el-form-item prop="Zsonorder">
                    <el-select
                      v-model="ruleForm.Zsonorder"
                      placeholder="请选择"
                      class="selectcss"
                      @change="Zsonorder"
                    >
                      <el-option label="1" value="1"></el-option>
                      <el-option label="2" value="2"></el-option>
                    </el-select>
                  </el-form-item>
                </td>
              </tr>
            </tbody>
          </table>
        </el-form-item>
        <el-form-item label="分润比例设置" prop="shareratio" label-width="108">
          <el-table :data="tableData" style="width: 80%" border size="mini">
            <el-table-column prop="objtype" label="分润对象类型">
            </el-table-column>
            <el-table-column prop="objname" label="分润对象名称">
            </el-table-column>
            <el-table-column prop="account" label="分润账户"> </el-table-column>
            <el-table-column prop="mode" label="分成方式"> </el-table-column>
            <el-table-column prop="money" label="分成比列/金额">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.money"
                  placeholder="请输入比列/金额"
                  size="mini"
                  type="number"
                  @blur="shareratio(scope.row)"
                  :disabled="scope.$index === 0 ? true : false"
                ></el-input>
              </template>
            </el-table-column>
          </el-table>
        </el-form-item>
        <el-form-item
          label="核销支出比例设置"
          prop="writeexpensessz"
          label-width="108"
        >
          <el-table
            :data="writeexpensesList"
            style="width: 60%"
            border
            size="mini"
          >
            <el-table-column prop="objtype" label="核销对象类型">
            </el-table-column>
            <el-table-column prop="objname" label="核销对象名称">
            </el-table-column>
            <el-table-column prop="mode" label="分成方式"> </el-table-column>
            <el-table-column prop="money" label="核销比列/金额">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.money"
                  placeholder="请输入比列/金额"
                  type="number"
                  size="mini"
                  @blur="writeexpensesszblur(scope.row)"
                ></el-input>
              </template>
            </el-table-column>
          </el-table>
        </el-form-item>
        <el-form-item
          label="核销收入比例设置"
          prop="writeincome"
          label-width="108"
        >
          <el-table
            :data="writeincomeList"
            style="width: 60%"
            border
            size="mini"
          >
            <el-table-column prop="objtype" label="核销对象类型">
            </el-table-column>
            <el-table-column prop="objname" label="核销对象名称">
            </el-table-column>
            <el-table-column prop="mode" label="分成方式"> </el-table-column>
            <el-table-column prop="money" label="核销比列/金额">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.money"
                  placeholder="请输入比列/金额"
                  type="number"
                  size="mini"
                  @blur="writeincomeblur(scope.row)"
                ></el-input>
              </template>
            </el-table-column>
          </el-table>
        </el-form-item>

        <el-form-item>
          <el-button
            type="primary"
            @click="submitForm('ruleForm')"
            v-loading.fullscreen.lock="fullscreenLoading"
            >立即提交</el-button
          >
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </div>
      <!-- 普通商户 -->
      <div v-else>
        <el-form-item label="所属加盟商" prop="franchisee">
          <el-select
            v-model="ruleForm.franchisee"
            placeholder="请选择所属加盟商"
            class="selectcss"
            @change="resourcesideClickJJ"
          >
            <el-option
              :label="item.storename"
              :value="index1"
              v-for="(item, index1) in resourcesideList"
              :key="index1"
            ></el-option>
          </el-select>
          <span
            class="color-blue font-12 mt-10 ml-10"
            @click="returndetails(5)"
            style="cursor: pointer"
            >新增加盟商</span
          >
        </el-form-item>
        <el-form-item label="商户地区">
          <selectCity :cityVal.sync="ruleForm.cityVal" type="2" />
        </el-form-item>
        <el-form-item
          label="分润比例设置"
          prop="profitobject"
          label-width="108"
        >
          <el-table :data="ordinaryList" style="width: 80%" border size="mini">
            <el-table-column prop="objtype" label="分润对象类型">
            </el-table-column>
            <el-table-column prop="objname" label="分润对象名称">
            </el-table-column>
            <el-table-column prop="account" label="分润账户"> </el-table-column>
            <el-table-column prop="mode" label="分成方式"> </el-table-column>
            <el-table-column prop="money" label="分成比列/金额">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.money"
                  placeholder="请输入比列/金额"
                  size="mini"
                  @blur="profitobjectblur(scope.row)"
                  :disabled="true"
                ></el-input>
              </template>
            </el-table-column>
          </el-table>
        </el-form-item>

        <el-form-item>
          <el-button
            type="primary"
            @click="submitFormpt('ruleForm')"
            v-loading.fullscreen.lock="fullscreenLoading"
            >立即提交</el-button
          >
        </el-form-item>
      </div>
    </el-form>
  </el-dialog>
</template>
<script>
import selectCity from "@/components/selectCity.vue";
import addPartner from "@/components/partner/addPartner.vue";
import { update } from "js-md5";
export default {
  name: "addEquipment",
  data() {
    return {
      titname: "新增合伙商户类型",
      ruleForm: {
        name: "", //类型
        resourceside: "", //所属资源方
        infrastructureside: "", //所属基建方
        venue: "", //所属场地方
        generalequipment: "", //所属总设备方
        subequipment: "", //所属子设备方
        partner: true, //合作方包含
        checked1: true, //合作方包含12345
        checked2: true,
        checked3: true,
        checked4: true,
        checked5: false,
        basicsorigina: "", //基建回本
        sonorigina: "", //子设备回本
        Zsonorigina: "", //总设备回本
        basicorder: "", //基建回本顺序
        sonorder: "", //子设备回本顺序
        Zsonorder: "", //总设备回本顺序
        franchisee: "", //加盟商

        region: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
        shareratio: "", //分成比列
        writeexpensessz: "", //分成比列
        writeincome: "", //分成比列
        profitobject: "", //分成比列
        // // 城市
        cityVal: [],
      },
      rules: {
        name: [{ required: true, message: "请选择类型", trigger: "blur" }],
        resourceside: [
          { required: true, message: "请选择所属资源方", trigger: "change" },
        ],
        infrastructureside: [
          { required: true, message: "请选择所属基建方", trigger: "change" },
        ],
        venue: [
          { required: true, message: "请选择所属场地方", trigger: "change" },
        ],
        generalequipment: [
          { required: true, message: "请选择所属总设备方", trigger: "change" },
        ],
        // subequipment: [
        //   { required: true, message: "请选择所属子设备方", trigger: "change" },
        // ],
        // basicsorigina: [{ required: true, message: " ", trigger: "change" }],
        // sonorigina: [{ required: true, message: " ", trigger: "change" }],
        // Zsonorigina: [{ required: true, message: " ", trigger: "change" }],
        // basicorder: [{ required: true, message: " ", trigger: "change" }],
        // sonorder: [{ required: true, message: " ", trigger: "change" }],
        // Zsonorder: [{ required: true, message: " ", trigger: "change" }],
        // shareratio: [
        //   { required: false, message: "请输入分润比列", trigger: "change" },
        // ],
        // writeexpensessz: [
        //   { required: false, message: "请输入核销支出", trigger: "change" },
        // ],
        // writeincome: [
        //   { required: false, message: "请输入核销收入", trigger: "change" },
        // ],
        // profitobject: [
        //   { required: false, message: "请输入分润比列", trigger: "change" },
        // ],
        // franchisee: [
        //   { required: false, message: "请输入分润比列", trigger: "change" },
        // ],
      },
      statusLists: [
        { id: 1, status_name: "普通商户类型" },
        { id: 2, status_name: "合伙商户类型" },
      ],
      partnership: true, //合伙商户类型
      // ordinary:false,//普通商户类型
      resourceside: true, //显示隐藏所属资源方
      infrastructureside: true, //基建方
      venue: true, //场地方
      generalequipment: true, //总设备方
      subequipment: false, //子设备方
      resourcesideList: [],
      //分润比例设置
      tableData: [
        {
          id: 6,
          objtype: "平台方",
          objname: "七迈车科技集团有限公司",
          account: "虚拟云账户",
          mode: "按订单比列",
          money: "0.08",
        },
        {
          id: 0,
          objtype: "资源方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.25",
          check: true,
        },
        {
          id: 1,
          objtype: "基建方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.10",
          check: true,
        },
        {
          id: 2,
          objtype: "场地方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.45",
          check: true,
        },
        {
          id: 3,
          objtype: "总设备方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.20",
          check: true,
        },
      ],
      //核销支出比例设置
      writeexpensesList: [
        {
          id: 0,
          objtype: "资源方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.25",
          check: true,
        },
        {
          id: 1,
          objtype: "基建方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.10",
          check: true,
        },
        {
          id: 2,
          objtype: "场地方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.45",
          check: true,
        },
        {
          id: 3,
          objtype: "总设备方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.20",
          check: true,
        },
      ],
      //核销收入比例设置
      writeincomeList: [
        {
          id: 0,
          objtype: "资源方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.25",
          check: true,
        },
        {
          id: 1,
          objtype: "基建方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.10",
          check: true,
        },
        {
          id: 2,
          objtype: "场地方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.45",
          check: true,
        },
        {
          id: 3,
          objtype: "总设备方",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台后按比例",
          money: "0.20",
          check: true,
        },
      ],
      //普通商户
      ordinaryList: [
        {
          id: 6,
          objtype: "平台方",
          objname: "七迈车科技集团有限公司",
          account: "虚拟云账户",
          mode: "按订单比列",
          money: "0.08",
        },
        {
          id: 0,
          objtype: "加盟商",
          objname: "",
          account: "虚拟云账户",
          mode: "扣除平台分润后按比例",
          money: "1",
          check: true,
        },
      ],
      storeidList: [], //店铺idlist

      addList: [
        {
          store_id: "", //店铺id
          merchant_type: 0, //商户类型
          proportion: 0.25, //分成比例 [小数 0-1 ]
          yeartype: 0, //第几年
          sequence: 0, //回本顺序 按从小到大排序
          isDeleted: true, //是否删除
          out_Proportion: 0.25, //核销支出比例
          in_Proportion: 0.25, //核销收入比例
          needpayoff: 0, //0不需要分成 1 需要分成
          dividemode: "", //分成方式
        },
        {
          store_id: "", //店铺id
          merchant_type: 1, //商户类型
          proportion: 0.1, //分成比例 [小数 0-1 ]
          yeartype: 0, //第几年
          sequence: 0, //回本顺序 按从小到大排序
          isDeleted: true, //是否删除
          out_Proportion: 0.1, //核销支出比例
          in_Proportion: 0.1, //核销收入比例
          needpayoff: 0, //0不需要分成 1 需要分成
          dividemode: "", //分成方式
        },
        {
          store_id: "", //店铺id
          merchant_type: 2, //商户类型
          proportion: 0.45, //分成比例 [小数 0-1 ]
          yeartype: 0, //第几年
          sequence: 0, //回本顺序 按从小到大排序
          isDeleted: true, //是否删除
          out_Proportion: 0.45, //核销支出比例
          in_Proportion: 0.45, //核销收入比例
          needpayoff: 0, //0不需要分成 1 需要分成
          dividemode: "", //分成方式
        },
        {
          store_id: "", //店铺id
          merchant_type: 3, //商户类型
          proportion: 0.2, //分成比例 [小数 0-1 ]
          yeartype: 0, //第几年
          sequence: 0, //回本顺序 按从小到大排序
          isDeleted: true, //是否删除
          out_Proportion: 0.2, //核销支出比例
          in_Proportion: 0.2, //核销收入比例
          needpayoff: 0, //0不需要分成 1 需要分成
          dividemode: "", //分成方式
        },
      ],
      addPTList: [
        {
          store_id: "", //店铺id
          merchant_type: 10, //商户类型
          proportion: 1, //分成比例 [小数 0-1 ]
          yeartype: 0, //第几年
          sequence: 0, //回本顺序 按从小到大排序
          isDeleted: true, //是否删除
          out_Proportion: 1, //核销支出比例
          in_Proportion: 1, //核销收入比例
          needpayoff: 0, //0不需要分成 1 需要分成
          dividemode: "", //分成方式
        },
      ],
      xqlist: [], //详情
      equibtu: true, //true新增，false编辑
      merchant_num: "", //商户号
      fullscreenLoading: false, //loading
      dialogVisibles: false,
      companyName: "", //公司名字
      newlyadded: "", //新增公司
    };
  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
  },
  created() {
    this.ruleForm.name = this.statusLists[1].id;
    this.GetAdminLeageStoreList();
  },
  components: {
    selectCity,
    addPartner,
  },
  methods: {
    //切换-标题显示
    parentMsg: function (msg) {
      if (msg.id !== undefined) {
        this.equibtu = false;
        this.titname = "编辑商户类型";
        this.GetAdminMerchantDetail(msg);
      } else {
        this.equibtu = true;
        this.titname = "新增合伙商户类型";
        this.partnership = true;
        this.ruleForm.name = this.statusLists[1].id;
        // this.ruleForm.cityVal[0]='';
        // this.ruleForm.cityVal[1]='';
        this.ruleForm.resourceside = "";
        this.ruleForm.infrastructureside = "";
        this.ruleForm.venue = "";
        this.ruleForm.generalequipment = "";
        this.ruleForm.basicsorigina = "";
        this.ruleForm.basicorder = "";
        this.ruleForm.subequipment = "";
        this.ruleForm.sonorigina = "";
        this.ruleForm.sonorder = "";
        this.ruleForm.Zsonorigina = "";
        this.ruleForm.Zsonorder = "";
        this.ruleForm.franchisee = "";
        this.subequipment = false;
        this.ruleForm.checked5 = false;
        this.tableData = [
          {
            id: 6,
            objtype: "平台方",
            objname: "七迈车科技集团有限公司",
            account: "虚拟云账户",
            mode: "按订单比列",
            money: "0.08",
          },
          {
            id: 0,
            objtype: "资源方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.25",
            check: true,
          },
          {
            id: 1,
            objtype: "基建方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.10",
            check: true,
          },
          {
            id: 2,
            objtype: "场地方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.45",
            check: true,
          },
          {
            id: 3,
            objtype: "总设备方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.20",
            check: true,
          },
        ];
        //核销支出比例设置
        this.writeexpensesList = [
          {
            id: 0,
            objtype: "资源方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.25",
            check: true,
          },
          {
            id: 1,
            objtype: "基建方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.10",
            check: true,
          },
          {
            id: 2,
            objtype: "场地方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.45",
            check: true,
          },
          {
            id: 3,
            objtype: "总设备方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.20",
            check: true,
          },
        ];
        //核销收入比例设置
        this.writeincomeList = [
          {
            id: 0,
            objtype: "资源方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.25",
            check: true,
          },
          {
            id: 1,
            objtype: "基建方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.10",
            check: true,
          },
          {
            id: 2,
            objtype: "场地方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.45",
            check: true,
          },
          {
            id: 3,
            objtype: "总设备方",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台后按比例",
            money: "0.20",
            check: true,
          },
        ];
        this.addList = [
          {
            store_id: "", //店铺id
            merchant_type: 0, //商户类型
            proportion: 0.25, //分成比例 [小数 0-1 ]
            yeartype: 0, //第几年
            sequence: 0, //回本顺序 按从小到大排序
            isDeleted: true, //是否删除
            out_Proportion: 0.25, //核销支出比例
            in_Proportion: 0.25, //核销收入比例
            needpayoff: 0, //0不需要分成 1 需要分成
            dividemode: "", //分成方式
          },
          {
            store_id: "", //店铺id
            merchant_type: 1, //商户类型
            proportion: 0.1, //分成比例 [小数 0-1 ]
            yeartype: 0, //第几年
            sequence: 0, //回本顺序 按从小到大排序
            isDeleted: true, //是否删除
            out_Proportion: 0.1, //核销支出比例
            in_Proportion: 0.1, //核销收入比例
            needpayoff: 0, //0不需要分成 1 需要分成
            dividemode: "", //分成方式
          },
          {
            store_id: "", //店铺id
            merchant_type: 2, //商户类型
            proportion: 0.45, //分成比例 [小数 0-1 ]
            yeartype: 0, //第几年
            sequence: 0, //回本顺序 按从小到大排序
            isDeleted: true, //是否删除
            out_Proportion: 0.45, //核销支出比例
            in_Proportion: 0.45, //核销收入比例
            needpayoff: 0, //0不需要分成 1 需要分成
            dividemode: "", //分成方式
          },
          {
            store_id: "", //店铺id
            merchant_type: 3, //商户类型
            proportion: 0.2, //分成比例 [小数 0-1 ]
            yeartype: 0, //第几年
            sequence: 0, //回本顺序 按从小到大排序
            isDeleted: true, //是否删除
            out_Proportion: 0.2, //核销支出比例
            in_Proportion: 0.2, //核销收入比例
            needpayoff: 0, //0不需要分成 1 需要分成
            dividemode: "", //分成方式
          },
        ];

        this.addPTList = [
          {
            store_id: "", //店铺id
            merchant_type: 10, //商户类型
            proportion: 1, //分成比例 [小数 0-1 ]
            yeartype: 0, //第几年
            sequence: 0, //回本顺序 按从小到大排序
            isDeleted: true, //是否删除
            out_Proportion: 1, //核销支出比例
            in_Proportion: 1, //核销收入比例
            needpayoff: 0, //0不需要分成 1 需要分成
            dividemode: "", //分成方式
          },
        ];

        this.ordinaryList = [
          {
            id: 6,
            objtype: "平台方",
            objname: "七迈车科技集团有限公司",
            account: "虚拟云账户",
            mode: "按订单比列",
            money: "0.08",
          },
          {
            id: 0,
            objtype: "加盟商",
            objname: "",
            account: "虚拟云账户",
            mode: "扣除平台分润后按比例",
            money: "1",
            check: true,
          },
        ];
      }
    },
    // 获取合作人下拉列表
    GetAdminLeageStoreList(names) {
      let data = {
        pageIndex: 1,
        pageSize: 50,
        searchname: names, //
      };
      this.$api.merchant.GetAdminLeageStoreList(data).then((res) => {
        this.resourcesideList = res.data.list;
      });
    },
    // 新增商户
    AddAdminAccountStoreMerchant(type) {
      let adl;
      let adltrue;
      if (type === 0) {
        adl = this.addList;
        if (adl.length < 1) {
          this.$message({
            type: "warning",
            message: "资源方、基建方、场地方、总设备方必须包含",
          });
          return false;
        }
        if (adl.length > 4) {
          if (adl[4].store_id === "") {
            this.$message({
              type: "warning",
              message: "请选择所属子设备方",
            });
            return false;
          }
        }
        if (adl[1].sequence === "1") {
          if (this.subequipment) {
            if (adl[4].sequence === "1") {
              this.$message({
                type: "warning",
                message: "回本顺序设置错误41",
              });
              return false;
            }
          } else {
            if (adl[3].sequence === "1") {
              this.$message({
                type: "warning",
                message: "回本顺序设置错误31",
              });
              return false;
            }
          }
        } else {
          if (this.subequipment) {
            if (adl[4].sequence === "2") {
              this.$message({
                type: "warning",
                message: "基建方和子设备方回本顺序不能相同",
              });
              return false;
            }
          } else {
            if (adl[3].sequence === "2") {
              this.$message({
                type: "warning",
                message: "基建方和总设备方回本顺序不能相同",
              });
              return false;
            }
          }
        }

        adltrue = true;
      } else {
        adl = this.addPTList;
        adltrue = false;
      }
      let data = {
        isleague: adltrue, //是否是合伙类型 true为合作类型
        provinceid: this.ruleForm.cityVal[0], //省id
        cityid: this.ruleForm.cityVal[1], //城市id
        addAdminAccountStoreMerchants: adl,
      };
      let _this = this;
      this.fullscreenLoading = true;
      // console.log(data)
      this.$api.merchant
        .AddAdminAccountStoreMerchant(data)
        .then((res) => {
          if (res.code === 200) {
            this.$message({
              message: "操作成功！",
              type: "success",
              duration: 1500,
            });
            this.fullscreenLoading = false;
            setTimeout(() => {
              this.$emit("update:dialogVisible", false);
            }, 1500);
          } else {
            this.$message({
              type: "success",
              message: res.data,
            });
            this.fullscreenLoading = false;
          }
        })
        .catch((err) => {
          this.fullscreenLoading = false;
        });
    },
    // 获取修改商户号详情
    GetAdminMerchantDetail(type) {
      this.merchant_num = type.merchant_num;
      let data = {
        merchant_num: type.merchant_num,
      };
      this.$api.merchant.GetAdminMerchantDetail(data).then((res) => {
        this.xqlist = res.data;
        let xqadmins = this.xqlist.adminAccountStoreMerchants;
        this.ruleForm.name = this.xqlist.type; //1 为普通 2为合作
        if (res.data.type === 2) {
          this.partnership = true;
          this.ruleForm.cityVal = [this.xqlist.provinceid, this.xqlist.cityid];
          this.ruleForm.resourceside = xqadmins[0].store_name;
          this.ruleForm.infrastructureside = xqadmins[1].store_name;
          this.ruleForm.venue = xqadmins[2].store_name;
          this.ruleForm.generalequipment = xqadmins[3].store_name;
          this.ruleForm.basicsorigina = String(xqadmins[1].needpayoff);
          this.ruleForm.basicorder = String(xqadmins[1].sequence);
          this.ruleForm.Zsonorigina = String(xqadmins[3].needpayoff); //0不需要分成 1 需要分成
          this.ruleForm.Zsonorder = String(xqadmins[3].sequence); //回本顺序
          this.subequipment = false;
          this.ruleForm.checked5 = false;
          this.ruleForm.subequipment = "";
          this.ruleForm.sonorigina = "";
          this.ruleForm.sonorder = "";
          // this.ruleForm.resourceside = xqadmins[0].store_name;
          //分润比例设置
          this.tableData = [
            {
              id: 6,
              objtype: "平台方",
              objname: "七迈车科技集团有限公司",
              account: "虚拟云账户",
              mode: "按订单比列",
              money: "0.08",
            },
            {
              id: 0,
              objtype: "资源方",
              objname: xqadmins[0].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[0].proportion,
              check: true,
            },
            {
              id: 1,
              objtype: "基建方",
              objname: xqadmins[1].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[1].proportion,
              check: true,
            },
            {
              id: 2,
              objtype: "场地方",
              objname: xqadmins[2].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[2].proportion,
              check: true,
            },
            {
              id: 3,
              objtype: "总设备方",
              objname: xqadmins[3].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[3].proportion,
              check: true,
            },
          ];
          //核销支出比例设置
          this.writeexpensesList = [
            {
              id: 0,
              objtype: "资源方",
              objname: xqadmins[0].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[0].out_Proportion,
              check: true,
            },
            {
              id: 1,
              objtype: "基建方",
              objname: xqadmins[1].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[1].out_Proportion,
              check: true,
            },
            {
              id: 2,
              objtype: "场地方",
              objname: xqadmins[2].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[2].out_Proportion,
              check: true,
            },
            {
              id: 3,
              objtype: "总设备方",
              objname: xqadmins[3].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[3].out_Proportion,
              check: true,
            },
          ];
          //核销收入比例设置
          this.writeincomeList = [
            {
              id: 0,
              objtype: "资源方",
              objname: xqadmins[0].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[0].in_Proportion,
              check: true,
            },
            {
              id: 1,
              objtype: "基建方",
              objname: xqadmins[1].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[1].in_Proportion,
              check: true,
            },
            {
              id: 2,
              objtype: "场地方",
              objname: xqadmins[2].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[2].in_Proportion,
              check: true,
            },
            {
              id: 3,
              objtype: "总设备方",
              objname: xqadmins[3].store_name,
              account: "虚拟云账户",
              mode: "扣除平台后按比例",
              money: xqadmins[3].in_Proportion,
              check: true,
            },
          ];
          this.addList = [
            {
              store_id: xqadmins[0].store_id, //店铺id
              merchant_type: xqadmins[0].merchant_type, //商户类型
              proportion: xqadmins[0].proportion, //分成比例 [小数 0-1 ]
              yeartype: xqadmins[0].yeartype, //第几年
              sequence: xqadmins[0].sequence, //回本顺序 按从小到大排序
              isDeleted: true, //是否删除
              out_Proportion: xqadmins[0].out_Proportion, //核销支出比例
              in_Proportion: xqadmins[0].in_Proportion, //核销收入比例
              needpayoff: xqadmins[0].needpayoff, //0不需要分成 1 需要分成
              dividemode: xqadmins[0].dividemode, //分成方式
            },
            {
              store_id: xqadmins[1].store_id, //店铺id
              merchant_type: xqadmins[1].merchant_type, //商户类型
              proportion: xqadmins[1].proportion, //分成比例 [小数 0-1 ]
              yeartype: xqadmins[1].yeartype, //第几年
              sequence: xqadmins[1].sequence, //回本顺序 按从小到大排序
              isDeleted: true, //是否删除
              out_Proportion: xqadmins[1].out_Proportion, //核销支出比例
              in_Proportion: xqadmins[1].in_Proportion, //核销收入比例
              needpayoff: xqadmins[1].needpayoff, //0不需要分成 1 需要分成
              dividemode: xqadmins[1].dividemode, //分成方式
            },
            {
              store_id: xqadmins[2].store_id, //店铺id
              merchant_type: xqadmins[2].merchant_type, //商户类型
              proportion: xqadmins[2].proportion, //分成比例 [小数 0-1 ]
              yeartype: xqadmins[2].yeartype, //第几年
              sequence: xqadmins[2].sequence, //回本顺序 按从小到大排序
              isDeleted: true, //是否删除
              out_Proportion: xqadmins[2].out_Proportion, //核销支出比例
              in_Proportion: xqadmins[2].in_Proportion, //核销收入比例
              needpayoff: xqadmins[2].needpayoff, //0不需要分成 1 需要分成
              dividemode: xqadmins[2].dividemode, //分成方式
            },
            {
              store_id: xqadmins[3].store_id, //店铺id
              merchant_type: xqadmins[3].merchant_type, //商户类型
              proportion: xqadmins[3].proportion, //分成比例 [小数 0-1 ]
              yeartype: xqadmins[3].yeartype, //第几年
              sequence: xqadmins[3].sequence, //回本顺序 按从小到大排序
              isDeleted: true, //是否删除
              out_Proportion: xqadmins[3].out_Proportion, //核销支出比例
              in_Proportion: xqadmins[3].in_Proportion, //核销收入比例
              needpayoff: xqadmins[3].needpayoff, //0不需要分成 1 需要分成
              dividemode: xqadmins[3].dividemode, //分成方式
            },
          ];

          //如果有5条数据，子设备方为true
          if (this.xqlist.adminAccountStoreMerchants.length > 4) {
            this.ruleForm.checked5 = true;
            this.subequipment = true;
            this.ruleForm.subequipment = xqadmins[4].store_name;
            this.ruleForm.sonorigina = String(xqadmins[4].needpayoff); //0不需要分成 1 需要分成
            this.ruleForm.sonorder = String(xqadmins[4].sequence); //回本顺序 1-1  2-2
            //分润比例
            let list1 = {
              id: 4,
              objtype: "子设备方",
              objname: xqadmins[4].store_name,
              account: "虚拟云账户",
              mode: "按总设备方分成比例平分",
              money: xqadmins[4].proportion,
              check: false,
            };
            let list2 = {
              id: 4,
              objtype: "子设备方",
              objname: xqadmins[4].store_name,
              account: "虚拟云账户",
              mode: "按总设备方分成比例平分",
              money: xqadmins[4].out_Proportion,
              check: false,
            };
            let list3 = {
              id: 4,
              objtype: "子设备方",
              objname: xqadmins[4].store_name,
              account: "虚拟云账户",
              mode: "按总设备方分成比例平分",
              money: xqadmins[4].in_Proportion,
              check: false,
            };
            let addzilist = {
              store_id: xqadmins[4].store_id, //店铺id
              merchant_type: xqadmins[4].merchant_type, //商户类型
              proportion: xqadmins[4].proportion, //分成比例 [小数 0-1 ]
              yeartype: xqadmins[4].yeartype, //第几年
              sequence: xqadmins[4].sequence, //回本顺序 按从小到大排序
              isDeleted: true, //是否删除
              out_Proportion: xqadmins[4].out_Proportion, //核销支出比例
              in_Proportion: xqadmins[4].in_Proportion, //核销收入比例
              needpayoff: xqadmins[4].needpayoff, //0不需要分成 1 需要分成
              dividemode: xqadmins[4].dividemode, //分成方式
            };
            this.tableData.push(list1); //分润比例设置
            this.writeexpensesList.push(list2); //核销支出比例设置
            this.writeincomeList.push(list3); ////核销收入比例设置
            this.addList.push(addzilist);
          }
        } else {
          //普通
          this.partnership = false;
          this.ruleForm.franchisee = this.xqlist.adminAccountStoreMerchants[0].store_name;
          this.ruleForm.cityVal = [this.xqlist.provinceid, this.xqlist.cityid];
          this.ordinaryList[1].objname = this.xqlist.adminAccountStoreMerchants[0].store_name;
          this.ordinaryList[1].money = this.xqlist.adminAccountStoreMerchants[0].proportion;

          this.addPTList[0].store_id = this.xqlist.adminAccountStoreMerchants[0].store_id;
          this.addPTList[0].merchant_type = this.xqlist.adminAccountStoreMerchants[0].merchant_type;
        }
      });
    },
    // 普通-修改商户
    EditAdminAccountStoreMerchant(type) {
      let adl;
      if (type === 0) {
        adl = this.addList;
      } else {
        adl = this.addPTList;
      }
      let data = {
        merchant_num: this.merchant_num, //商户号
        provinceid: this.ruleForm.cityVal[0], //省id
        cityid: this.ruleForm.cityVal[1], //城市id
        addAdminAccountStoreMerchants: adl,
      };
      let _this = this;
      this.fullscreenLoading = true;
      // console.log(data)
      this.$api.merchant
        .EditAdminAccountStoreMerchant(data)
        .then((res) => {
          if (res.code === 200) {
            this.$message({
              message: "操作成功！",
              type: "success",
              duration: 1500,
            });
            this.fullscreenLoading = false;
            setTimeout(() => {
              this.$emit("update:dialogVisible", false);
            }, 1500);
          } else {
            this.$message({
              type: "success",
              message: res.data,
            });
            this.fullscreenLoading = false;
          }
        })
        .catch((err) => {
          this.fullscreenLoading = false;
        });
    },
    handleClose() {
      this.$emit("closeAdd");
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (!this.resourceside) {
            this.$message({
              type: "warning",
              message: "资源方、基建方、场地方、总设备方必须包含",
            });
            return false;
          }
          if (!this.infrastructureside) {
            this.$message({
              type: "warning",
              message: "资源方、基建方、场地方、总设备方必须包含",
            });
            return false;
          }
          if (!this.venue) {
            this.$message({
              type: "warning",
              message: "资源方、基建方、场地方、总设备方必须包含",
            });
            return false;
          }
          if (!this.generalequipment) {
            this.$message({
              type: "warning",
              message: "资源方、基建方、场地方、总设备方必须包含",
            });
            return false;
          }
          if (this.ruleForm.resourceside === "") {
            this.$message({
              type: "warning",
              message: "请选择所属资源方",
            });
            return false;
          }
          if (this.ruleForm.infrastructureside === "") {
            this.$message({
              type: "warning",
              message: "请选择所属基建方",
            });
            return false;
          }
          if (this.ruleForm.venue === "") {
            this.$message({
              type: "warning",
              message: "请选择所属场地方",
            });
            return false;
          }
          if (this.ruleForm.generalequipment === "") {
            this.$message({
              type: "warning",
              message: "请选择所属总设备方",
            });
            return false;
          }
          if (this.ruleForm.basicsorigina === "") {
            this.$message({
              type: "warning",
              message: "回本设置必须选择",
            });
            return false;
          }
          if (this.ruleForm.basicorder === "") {
            this.$message({
              type: "warning",
              message: "回本设置必须选择",
            });
            return false;
          }

          //子设备方
          if (this.subequipment) {
            if (this.ruleForm.sonorigina === "") {
              //是否回本
              this.$message({
                type: "warning",
                message: "回本设置必须选择",
              });
              return false;
            }
            if (this.ruleForm.sonorder === "") {
              //回本顺序
              this.$message({
                type: "warning",
                message: "回本设置必须选择",
              });
              return false;
            }
            if (this.ruleForm.basicorder === "1") {
              //基建回本
              if (this.ruleForm.sonorder === "1") {
                //子回本
                this.$message({
                  type: "warning",
                  message: "基建方和子设备方回本顺序不能相同",
                });
                return false;
              }
            } else {
              console.log("zijizizi", this.ruleForm.sonorder);
              if (this.ruleForm.sonorder === "2") {
                //子回本
                this.$message({
                  type: "warning",
                  message: "基建方和子设备方回本顺序不能相同",
                });
                return false;
              }
            }
          } else {
            if (this.ruleForm.Zsonorigina === "") {
              this.$message({
                type: "warning",
                message: "回本设置必须选择",
              });
              return false;
            }
            if (this.ruleForm.Zsonorder === "") {
              this.$message({
                type: "warning",
                message: "回本设置必须选择",
              });
              return false;
            }
            if (this.ruleForm.basicorder === "1") {
              //基建回本
              if (this.ruleForm.Zsonorder === "1") {
                //总回本
                this.$message({
                  type: "warning",
                  message: "基建方和总设备方回本顺序不能相同",
                });
                return false;
              }
            } else {
              if (this.ruleForm.Zsonorder === "2") {
                //总回本
                this.$message({
                  type: "warning",
                  message: "基建方和总设备方回本顺序不能相同",
                });
                return false;
              }
            }
          }
          if (this.equibtu === false) {
            this.EditAdminAccountStoreMerchant(0);
          } else {
            this.AddAdminAccountStoreMerchant(0);
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    //普通提交
    submitFormpt(formName) {
      if (this.ruleForm.franchisee === "") {
        this.$message({
          type: "warning",
          message: "请选择所属加盟商",
        });
        return false;
      }
      if (this.equibtu === false) {
        this.EditAdminAccountStoreMerchant(1);
      } else {
        this.AddAdminAccountStoreMerchant(1);
      }
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    // 商户类型选择
    selectClick(type) {
      if (type === 2) {
        this.partnership = true;
        this.titname = "新增合伙商户类型";
      } else {
        this.partnership = false;
        this.titname = "新增普通商户类型";
      }
    },
    //所属资源方
    resourcesideClick(type) {
      this.addList[0].store_id = this.resourcesideList[type].storeid;
      this.tableData[1].objname = this.resourcesideList[type].storename;
      this.writeexpensesList[0].objname = this.resourcesideList[type].storename;
      this.writeincomeList[0].objname = this.resourcesideList[type].storename;
    },
    //基建方
    infrastructuresideClick(type) {
      this.addList[1].store_id = this.resourcesideList[type].storeid;
      this.tableData[2].objname = this.resourcesideList[type].storename;
      this.writeexpensesList[1].objname = this.resourcesideList[type].storename;
      this.writeincomeList[1].objname = this.resourcesideList[type].storename;
    },
    //场地方
    venueClick(type) {
      this.addList[2].store_id = this.resourcesideList[type].storeid;
      this.tableData[3].objname = this.resourcesideList[type].storename;
      this.writeexpensesList[2].objname = this.resourcesideList[type].storename;
      this.writeincomeList[2].objname = this.resourcesideList[type].storename;
    },
    //总设备方
    generalequipmentClick(type) {
      this.addList[3].store_id = this.resourcesideList[type].storeid;
      this.tableData[4].objname = this.resourcesideList[type].storename;
      this.writeexpensesList[3].objname = this.resourcesideList[type].storename;
      this.writeincomeList[3].objname = this.resourcesideList[type].storename;
    },
    //子设备方
    subequipmentClick(type) {
      this.addList[4].store_id = this.resourcesideList[type].storeid;
      this.tableData[5].objname = this.resourcesideList[type].storename;
      this.writeexpensesList[4].objname = this.resourcesideList[type].storename;
      this.writeincomeList[4].objname = this.resourcesideList[type].storename;
    },
    //普通——加盟商
    resourcesideClickJJ(type) {
      this.addPTList[0].store_id = this.resourcesideList[type].storeid;
      this.ordinaryList[1].objname = this.resourcesideList[type].storename;
    },
    //回本
    basicsorigina(type) {
      console.log("是否会被基建方", type);
      this.addList[1].needpayoff = type;
      console.log("所属基建方", this.addList);
    },
    sonorigina(type) {
      console.log("是否子设备方", type);
      this.addList[4].needpayoff = type;
      console.log("是否子设备方", this.addList);
    },
    Zsonorigina(type) {
      console.log("是否总设备方", type);
      this.addList[3].needpayoff = type;
      console.log("是否总设备方", this.addList);
    },
    basicorder(type) {
      console.log("基建回本顺序", type);
      this.addList[1].sequence = type;
      console.log("基建回本顺序", this.addList);
    },
    sonorder(type) {
      console.log("子设备回本顺序", type);
      this.addList[4].sequence = type;
      console.log("子设备回本顺序", this.addList);
    },
    Zsonorder(type) {
      console.log("总设备回本顺序", type);
      this.addList[3].sequence = type;
      console.log("总设备回本顺序", this.addList);
    },
    //分润比列
    shareratio(event) {
      if (Number(event.money) > 1 || Number(event.money) < 0 || event.money === '' ) {
        this.$message({
          type: "warning",
          message: "不能大于1或小于0也不能为空",
        });
        this.tableData[event.id + 1].money = 0;
        this.addList[event.id].proportion = 0;
        return false;
      } else {
        this.addList[event.id].proportion = event.money;
        console.log("分润比列", this.addList);
      }
    },

    writeexpensesszblur(event) {
      if (Number(event.money) > 1 || Number(event.money) < 0 || event.money === '') {
        this.$message({
          type: "warning",
          message: "不能大于1或小于0也不能为空",
        });
        this.writeexpensesList[event.id].money = 0;
        this.addList[event.id].out_Proportion = 0;
        return false;
      } else {
        this.addList[event.id].out_Proportion = event.money;
        console.log("分润比列", this.addList);
      }
    },
    writeincomeblur(event) {
      if (Number(event.money) > 1 || Number(event.money) < 0 || event.money === '') {
        this.$message({
          type: "warning",
          message: "不能大于1或小于0也不能为空",
        });
        this.writeincomeList[event.id].money = 0;
        this.addList[event.id].in_Proportion = 0;
        return false;
      } else {
        this.addList[event.id].in_Proportion = event.money;
        console.log("分润比列", this.addList);
      }
    },

    profitobjectblur(event) {
      this.addPTList[event.id].in_Proportion = event.money;
      console.log("分润比列", event);
    },

    // 合作方包含事件12345
    checked1(type) {
      if (type) {
        this.resourceside = true;
      } else {
        this.resourceside = false;
      }
    },
    checked2(type) {
      if (type) {
        this.infrastructureside = true;
      } else {
        this.infrastructureside = false;
      }
    },
    checked3(type) {
      if (type) {
        this.venue = true;
      } else {
        this.venue = false;
      }
    },
    checked4(type) {
      if (type) {
        this.generalequipment = true;
      } else {
        this.generalequipment = false;
      }
    },
    checked5(type) {
      if (type) {
        this.subequipment = true;
        //分润比例
        let list1 = {
          id: 4,
          objtype: "子设备方",
          objname: "",
          account: "虚拟云账户",
          mode: "按总设备方分成比例平分",
          money: "0.50",
          check: false,
        };
        let list2 = {
          id: 4,
          objtype: "子设备方",
          objname: "",
          account: "虚拟云账户",
          mode: "按总设备方分成比例平分",
          money: "0.50",
          check: false,
        };
        let list3 = {
          id: 4,
          objtype: "子设备方",
          objname: "",
          account: "虚拟云账户",
          mode: "按总设备方分成比例平分",
          money: "0.50",
          check: false,
        };
        let addzilist = {
          store_id: "", //店铺id
          merchant_type: 4, //商户类型
          proportion: 0.5, //分成比例 [小数 0-1 ]
          yeartype: 0, //第几年
          sequence: 0, //回本顺序 按从小到大排序
          isDeleted: true, //是否删除
          out_Proportion: 0.5, //核销支出比例
          in_Proportion: 0.5, //核销收入比例
          needpayoff: 0, //0不需要分成 1 需要分成
          dividemode: "", //分成方式
        };
        this.tableData.push(list1);
        this.writeexpensesList.push(list2);
        this.writeincomeList.push(list3);
        this.addList.push(addzilist);
      } else {
        this.subequipment = false;
        this.tableData.splice(5, 1); //取消
        this.writeexpensesList.splice(4, 1); //取消
        this.writeincomeList.splice(4, 1); //取消
        this.addList.splice(4, 1); //取消
      }
    },
    //打开弹框
    returndetails(type) {
      this.dialogVisibles = true;
      this.newlyadded = type;
    },
    //新增合伙商
    getSonText(text) {
      this.GetAdminLeageStoreList();
      this.companyName = text;
      let comnum;
      //  this.ruleForm.resourceside = '七迈车科技集团有限公司'
      if (this.newlyadded === 0) {
        this.ruleForm.resourceside = text;
        this.resourcesideList.forEach((item, index) => {
          if (this.companyName === item.storename) {
            // console.log(item.storeid);
            console.log(index);
            console.log(item.storename);
            comnum = index;
          }
        });
        this.resourcesideClick(comnum);
      }
      if (this.newlyadded === 1) {
        this.ruleForm.infrastructureside = text;
        this.resourcesideList.forEach((item, index) => {
          if (this.companyName === item.storename) {
            // console.log(item.storeid);
            console.log(index);
            console.log(item.storename);
            comnum = index;
          }
        });
        this.infrastructuresideClick(comnum);
      }
      if (this.newlyadded === 2) {
        this.ruleForm.venue = text;
        this.resourcesideList.forEach((item, index) => {
          if (this.companyName === item.storename) {
            // console.log(item.storeid);
            console.log(index);
            console.log(item.storename);
            comnum = index;
          }
        });
        this.venueClick(comnum);
      }
      if (this.newlyadded === 3) {
        this.ruleForm.generalequipment = text;
        this.resourcesideList.forEach((item, index) => {
          if (this.companyName === item.storename) {
            // console.log(item.storeid);
            console.log(index);
            console.log(item.storename);
            comnum = index;
          }
        });
        this.generalequipmentClick(comnum);
      }
      if (this.newlyadded === 4) {
        this.ruleForm.subequipment = text;
        this.resourcesideList.forEach((item, index) => {
          if (this.companyName === item.storename) {
            // console.log(item.storeid);
            console.log(index);
            console.log(item.storename);
            comnum = index;
          }
        });
        this.subequipmentClick(comnum);
      }
      //普通加盟商
      if (this.newlyadded === 5) {
        this.ruleForm.franchisee = text;
        this.resourcesideList.forEach((item, index) => {
          if (this.companyName === item.storename) {
            // console.log(item.storeid);
            console.log(index);
            console.log(item.storename);
            comnum = index;
          }
        });
        this.resourcesideClickJJ(comnum);
      }
    },
    remoteMethod(query) {
        this.loading = true;
      if (query !== "") {
        // setTimeout(() => {
          this.GetAdminLeageStoreList(query);
          this.loading = false;
        // }, 200);
      } else {
          this.GetAdminLeageStoreList();
          this.loading = false;
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.add-form {
  border-bottom: 2px solid #d1d1d1;
  margin-bottom: 20px;
}
.pr-20 {
  padding-right: 20px;
}
.bg-f00 {
  background: #f00;
}
.add-type {
  width: 300px;
  line-height: 36px;
}
.btn-wrap {
  text-align: center;
}
.el-select {
  width: 80%;
}
// .selectcss {
//   width: 750px;
// }
.partitle {
  margin-top: -20px;
}
.tablecss {
  border: 1px solid #dcdfe6;
  border-collapse: collapse;
  width: 80%;
}
tr,
th,
td {
  text-align: center;
  border: 1px solid #dcdfe6;
  padding: 10px;
}
</style>
